package com.xjm.i1.core.struct.node.write;

import cn.hutool.core.util.NumberUtil;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 颜色色差与密度的公式计算数据
 * */
@Data
public class ExcelDiffDensityExtend {

    private double formulaTotalCyanL;
    private double formulaTotalCyanA;
    private double formulaTotalCyanB;
    private double formulaCyanMutil;

    private double formulaTotalMagentaL;
    private double formulaTotalMagentaA;
    private double formulaTotalMagentaB;
    private double formulaMagentaMutil;

    private double formulaTotalYellowL;
    private double formulaTotalYellowA;
    private double formulaTotalYellowB;
    private double formulaYellowMutil;

    private double formulaTotalBlackL;
    private double formulaTotalBlackA;
    private double formulaTotalBlackB;
    private double formulaBlackMutil;

    private double formulaTotalRedL;
    private double formulaTotalRedA;
    private double formulaTotalRedB;
    private double formulaRedMutil;

    private double formulaTotalGreenL;
    private double formulaTotalGreenA;
    private double formulaTotalGreenB;
    private double formulaGreenMutil;

    private double formulaTotalBlueL;
    private double formulaTotalBlueA;
    private double formulaTotalBlueB;
    private double formulaBlueMutil;

    public void setCyanParams(List<ExcelDiffDensity> cyanParams) {
        double l=0.0D, a=0.0D, b=0.0D;
        List<Double> dAVGS = new ArrayList<>(cyanParams.size());
        double total = cyanParams.size()*5.0D;
        for (ExcelDiffDensity diffDensity : cyanParams) {
            l+=diffDensity.getValueDLL();
            l+=diffDensity.getValueDRL();
            l+=diffDensity.getValueML();
            l+=diffDensity.getValueURL();
            l+=diffDensity.getValueULL();

            a+=diffDensity.getValueDLA();
            a+=diffDensity.getValueDRA();
            a+=diffDensity.getValueMA();
            a+=diffDensity.getValueURA();
            a+=diffDensity.getValueULA();

            b+=diffDensity.getValueULB();
            b+=diffDensity.getValueURB();
            b+=diffDensity.getValueMB();
            b+=diffDensity.getValueDRB();
            b+=diffDensity.getValueDLB();

            dAVGS.add(diffDensity.getFormulaDensityAVG());
        }
        this.formulaTotalCyanL = l/total;
        this.formulaTotalCyanA = a/total;
        this.formulaTotalCyanB = b/total;
        this.formulaCyanMutil = NumberUtil.max(dAVGS.toArray(new Double[cyanParams.size()]))
                -NumberUtil.min(dAVGS.toArray(new Double[cyanParams.size()]));

        for (ExcelDiffDensity diffDensity : cyanParams) {
            diffDensity.setFormulaDRLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalCyanL - diffDensity.getValueDRL(), 2)
                            +Math.pow(this.formulaTotalCyanA - diffDensity.getValueDRA(), 2)
                            +Math.pow(this.formulaTotalCyanB - diffDensity.getValueDRB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaDLLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalCyanL - diffDensity.getValueDLL(), 2)
                            +Math.pow(this.formulaTotalCyanA - diffDensity.getValueDLA(), 2)
                            +Math.pow(this.formulaTotalCyanB - diffDensity.getValueDLB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaURLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalCyanL - diffDensity.getValueURL(), 2)
                            +Math.pow(this.formulaTotalCyanA - diffDensity.getValueURA(), 2)
                            +Math.pow(this.formulaTotalCyanB - diffDensity.getValueURB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaULLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalCyanL - diffDensity.getValueULL(), 2)
                            +Math.pow(this.formulaTotalCyanA - diffDensity.getValueULA(), 2)
                            +Math.pow(this.formulaTotalCyanB - diffDensity.getValueULB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaMLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalCyanL - diffDensity.getValueML(), 2)
                            +Math.pow(this.formulaTotalCyanA - diffDensity.getValueMA(), 2)
                            +Math.pow(this.formulaTotalCyanB - diffDensity.getValueMB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaLABAVG(diffDensity.calculateLABAVG());
        }
    }

    public void setYellowParams(List<ExcelDiffDensity> yellowParams) {
        double l=0.0D, a=0.0D, b=0.0D;
        List<Double> dAVGS = new ArrayList<>(yellowParams.size());
        double total = yellowParams.size()*5.0D;
        for (ExcelDiffDensity diffDensity : yellowParams) {
            l+=diffDensity.getValueDLL();
            l+=diffDensity.getValueDRL();
            l+=diffDensity.getValueML();
            l+=diffDensity.getValueURL();
            l+=diffDensity.getValueULL();

            a+=diffDensity.getValueDLA();
            a+=diffDensity.getValueDRA();
            a+=diffDensity.getValueMA();
            a+=diffDensity.getValueURA();
            a+=diffDensity.getValueULA();

            b+=diffDensity.getValueULB();
            b+=diffDensity.getValueURB();
            b+=diffDensity.getValueMB();
            b+=diffDensity.getValueDRB();
            b+=diffDensity.getValueDLB();

            dAVGS.add(diffDensity.getFormulaDensityAVG());
        }
        this.formulaTotalYellowL = l/total;
        this.formulaTotalYellowA = a/total;
        this.formulaTotalYellowB = b/total;
        this.formulaYellowMutil = NumberUtil.max(dAVGS.toArray(new Double[yellowParams.size()]))
                -NumberUtil.min(dAVGS.toArray(new Double[yellowParams.size()]));

        for (ExcelDiffDensity diffDensity : yellowParams) {
            diffDensity.setFormulaDRLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalYellowL - diffDensity.getValueDRL(), 2)
                            +Math.pow(this.formulaTotalYellowA - diffDensity.getValueDRA(), 2)
                            +Math.pow(this.formulaTotalYellowB - diffDensity.getValueDRB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaDLLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalYellowL - diffDensity.getValueDLL(), 2)
                            +Math.pow(this.formulaTotalYellowA - diffDensity.getValueDLA(), 2)
                            +Math.pow(this.formulaTotalYellowB - diffDensity.getValueDLB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaURLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalYellowL - diffDensity.getValueURL(), 2)
                            +Math.pow(this.formulaTotalYellowA - diffDensity.getValueURA(), 2)
                            +Math.pow(this.formulaTotalYellowB - diffDensity.getValueURB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaULLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalYellowL - diffDensity.getValueULL(), 2)
                            +Math.pow(this.formulaTotalYellowA - diffDensity.getValueULA(), 2)
                            +Math.pow(this.formulaTotalYellowB - diffDensity.getValueULB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaMLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalYellowL - diffDensity.getValueML(), 2)
                            +Math.pow(this.formulaTotalYellowA - diffDensity.getValueMA(), 2)
                            +Math.pow(this.formulaTotalYellowB - diffDensity.getValueMB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaLABAVG(diffDensity.calculateLABAVG());
        }
    }

    public void setMagentaParams(List<ExcelDiffDensity> magentaParams) {
        double l=0.0D, a=0.0D, b=0.0D;
        List<Double> dAVGS = new ArrayList<>(magentaParams.size());
        double total = magentaParams.size()*5.0D;
        for (ExcelDiffDensity diffDensity : magentaParams) {
            l+=diffDensity.getValueDLL();
            l+=diffDensity.getValueDRL();
            l+=diffDensity.getValueML();
            l+=diffDensity.getValueURL();
            l+=diffDensity.getValueULL();

            a+=diffDensity.getValueDLA();
            a+=diffDensity.getValueDRA();
            a+=diffDensity.getValueMA();
            a+=diffDensity.getValueURA();
            a+=diffDensity.getValueULA();

            b+=diffDensity.getValueULB();
            b+=diffDensity.getValueURB();
            b+=diffDensity.getValueMB();
            b+=diffDensity.getValueDRB();
            b+=diffDensity.getValueDLB();

            dAVGS.add(diffDensity.getFormulaDensityAVG());
        }
        this.formulaTotalMagentaL = l/total;
        this.formulaTotalMagentaA = a/total;
        this.formulaTotalMagentaB = b/total;
        this.formulaMagentaMutil = NumberUtil.max(dAVGS.toArray(new Double[magentaParams.size()]))
                -NumberUtil.min(dAVGS.toArray(new Double[magentaParams.size()]));

        for (ExcelDiffDensity diffDensity : magentaParams) {
            diffDensity.setFormulaDRLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalMagentaL - diffDensity.getValueDRL(), 2)
                            +Math.pow(this.formulaTotalMagentaA - diffDensity.getValueDRA(), 2)
                            +Math.pow(this.formulaTotalMagentaB - diffDensity.getValueDRB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaDLLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalMagentaL - diffDensity.getValueDLL(), 2)
                            +Math.pow(this.formulaTotalMagentaA - diffDensity.getValueDLA(), 2)
                            +Math.pow(this.formulaTotalMagentaB - diffDensity.getValueDLB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaURLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalMagentaL - diffDensity.getValueURL(), 2)
                            +Math.pow(this.formulaTotalMagentaA - diffDensity.getValueURA(), 2)
                            +Math.pow(this.formulaTotalMagentaB - diffDensity.getValueURB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaULLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalMagentaL - diffDensity.getValueULL(), 2)
                            +Math.pow(this.formulaTotalMagentaA - diffDensity.getValueULA(), 2)
                            +Math.pow(this.formulaTotalMagentaB - diffDensity.getValueULB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaMLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalMagentaL - diffDensity.getValueML(), 2)
                            +Math.pow(this.formulaTotalMagentaA - diffDensity.getValueMA(), 2)
                            +Math.pow(this.formulaTotalMagentaB - diffDensity.getValueMB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaLABAVG(diffDensity.calculateLABAVG());
        }
    }

    public void setBlackParams(List<ExcelDiffDensity> blackParams) {
        double l=0.0D, a=0.0D, b=0.0D;
        List<Double> dAVGS = new ArrayList<>(blackParams.size());
        double total = blackParams.size()*5.0D;
        for (ExcelDiffDensity diffDensity : blackParams) {
            l+=diffDensity.getValueDLL();
            l+=diffDensity.getValueDRL();
            l+=diffDensity.getValueML();
            l+=diffDensity.getValueURL();
            l+=diffDensity.getValueULL();

            a+=diffDensity.getValueDLA();
            a+=diffDensity.getValueDRA();
            a+=diffDensity.getValueMA();
            a+=diffDensity.getValueURA();
            a+=diffDensity.getValueULA();

            b+=diffDensity.getValueULB();
            b+=diffDensity.getValueURB();
            b+=diffDensity.getValueMB();
            b+=diffDensity.getValueDRB();
            b+=diffDensity.getValueDLB();

            dAVGS.add(diffDensity.getFormulaDensityAVG());
        }
        this.formulaTotalBlackL = l/total;
        this.formulaTotalBlackA = a/total;
        this.formulaTotalBlackB = b/total;
        this.formulaBlackMutil = NumberUtil.max(dAVGS.toArray(new Double[blackParams.size()]))
                -NumberUtil.min(dAVGS.toArray(new Double[blackParams.size()]));

        for (ExcelDiffDensity diffDensity : blackParams) {
            diffDensity.setFormulaDRLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlackL - diffDensity.getValueDRL(), 2)
                            +Math.pow(this.formulaTotalBlackA - diffDensity.getValueDRA(), 2)
                            +Math.pow(this.formulaTotalBlackB - diffDensity.getValueDRB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaDLLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlackL - diffDensity.getValueDLL(), 2)
                            +Math.pow(this.formulaTotalBlackA - diffDensity.getValueDLA(), 2)
                            +Math.pow(this.formulaTotalBlackB - diffDensity.getValueDLB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaURLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlackL - diffDensity.getValueURL(), 2)
                            +Math.pow(this.formulaTotalBlackA - diffDensity.getValueURA(), 2)
                            +Math.pow(this.formulaTotalBlackB - diffDensity.getValueURB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaULLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlackL - diffDensity.getValueULL(), 2)
                            +Math.pow(this.formulaTotalBlackA - diffDensity.getValueULA(), 2)
                            +Math.pow(this.formulaTotalBlackB - diffDensity.getValueULB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaMLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlackL - diffDensity.getValueML(), 2)
                            +Math.pow(this.formulaTotalBlackA - diffDensity.getValueMA(), 2)
                            +Math.pow(this.formulaTotalBlackB - diffDensity.getValueMB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaLABAVG(diffDensity.calculateLABAVG());
        }
    }

    public void setRedParams(List<ExcelDiffDensity> redParams) {
        double l=0.0D, a=0.0D, b=0.0D;
        List<Double> dAVGS = new ArrayList<>(redParams.size());
        double total = redParams.size()*5.0D;
        for (ExcelDiffDensity diffDensity : redParams) {
            l+=diffDensity.getValueDLL();
            l+=diffDensity.getValueDRL();
            l+=diffDensity.getValueML();
            l+=diffDensity.getValueURL();
            l+=diffDensity.getValueULL();

            a+=diffDensity.getValueDLA();
            a+=diffDensity.getValueDRA();
            a+=diffDensity.getValueMA();
            a+=diffDensity.getValueURA();
            a+=diffDensity.getValueULA();

            b+=diffDensity.getValueULB();
            b+=diffDensity.getValueURB();
            b+=diffDensity.getValueMB();
            b+=diffDensity.getValueDRB();
            b+=diffDensity.getValueDLB();

            dAVGS.add(diffDensity.getFormulaDensityAVG());
        }
        this.formulaTotalRedL = l/total;
        this.formulaTotalRedA = a/total;
        this.formulaTotalRedB = b/total;
        this.formulaRedMutil = NumberUtil.max(dAVGS.toArray(new Double[redParams.size()]))
                -NumberUtil.min(dAVGS.toArray(new Double[redParams.size()]));

        for (ExcelDiffDensity diffDensity : redParams) {
            diffDensity.setFormulaDRLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalRedL - diffDensity.getValueDRL(), 2)
                            +Math.pow(this.formulaTotalRedA - diffDensity.getValueDRA(), 2)
                            +Math.pow(this.formulaTotalRedB - diffDensity.getValueDRB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaDLLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalRedL - diffDensity.getValueDLL(), 2)
                            +Math.pow(this.formulaTotalRedA - diffDensity.getValueDLA(), 2)
                            +Math.pow(this.formulaTotalRedB - diffDensity.getValueDLB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaURLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalRedL - diffDensity.getValueURL(), 2)
                            +Math.pow(this.formulaTotalRedA - diffDensity.getValueURA(), 2)
                            +Math.pow(this.formulaTotalRedB - diffDensity.getValueURB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaULLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalRedL - diffDensity.getValueULL(), 2)
                            +Math.pow(this.formulaTotalRedA - diffDensity.getValueULA(), 2)
                            +Math.pow(this.formulaTotalRedB - diffDensity.getValueULB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaMLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalRedL - diffDensity.getValueML(), 2)
                            +Math.pow(this.formulaTotalRedA - diffDensity.getValueMA(), 2)
                            +Math.pow(this.formulaTotalRedB - diffDensity.getValueMB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaLABAVG(diffDensity.calculateLABAVG());
        }
    }

    public void setGreenParams(List<ExcelDiffDensity> greenParams) {
        double l=0.0D, a=0.0D, b=0.0D;
        List<Double> dAVGS = new ArrayList<>(greenParams.size());
        double total = greenParams.size()*5.0D;
        for (ExcelDiffDensity diffDensity : greenParams) {
            l+=diffDensity.getValueDLL();
            l+=diffDensity.getValueDRL();
            l+=diffDensity.getValueML();
            l+=diffDensity.getValueURL();
            l+=diffDensity.getValueULL();

            a+=diffDensity.getValueDLA();
            a+=diffDensity.getValueDRA();
            a+=diffDensity.getValueMA();
            a+=diffDensity.getValueURA();
            a+=diffDensity.getValueULA();

            b+=diffDensity.getValueULB();
            b+=diffDensity.getValueURB();
            b+=diffDensity.getValueMB();
            b+=diffDensity.getValueDRB();
            b+=diffDensity.getValueDLB();

            dAVGS.add(diffDensity.getFormulaDensityAVG());
        }
        this.formulaTotalGreenL = l/total;
        this.formulaTotalGreenA = a/total;
        this.formulaTotalGreenB = b/total;
        this.formulaGreenMutil = NumberUtil.max(dAVGS.toArray(new Double[greenParams.size()]))
                -NumberUtil.min(dAVGS.toArray(new Double[greenParams.size()]));

        for (ExcelDiffDensity diffDensity : greenParams) {
            diffDensity.setFormulaDRLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalGreenL - diffDensity.getValueDRL(), 2)
                            +Math.pow(this.formulaTotalGreenA - diffDensity.getValueDRA(), 2)
                            +Math.pow(this.formulaTotalGreenB - diffDensity.getValueDRB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaDLLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalGreenL - diffDensity.getValueDLL(), 2)
                            +Math.pow(this.formulaTotalGreenA - diffDensity.getValueDLA(), 2)
                            +Math.pow(this.formulaTotalGreenB - diffDensity.getValueDLB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaURLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalGreenL - diffDensity.getValueURL(), 2)
                            +Math.pow(this.formulaTotalGreenA - diffDensity.getValueURA(), 2)
                            +Math.pow(this.formulaTotalGreenB - diffDensity.getValueURB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaULLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalGreenL - diffDensity.getValueULL(), 2)
                            +Math.pow(this.formulaTotalGreenA - diffDensity.getValueULA(), 2)
                            +Math.pow(this.formulaTotalGreenB - diffDensity.getValueULB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaMLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalGreenL - diffDensity.getValueML(), 2)
                            +Math.pow(this.formulaTotalGreenA - diffDensity.getValueMA(), 2)
                            +Math.pow(this.formulaTotalGreenB - diffDensity.getValueMB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaLABAVG(diffDensity.calculateLABAVG());
        }
    }

    public void setBlueParams(List<ExcelDiffDensity> blueParams) {
        double l=0.0D, a=0.0D, b=0.0D;
        List<Double> dAVGS = new ArrayList<>(blueParams.size());
        double total = blueParams.size()*5.0D;
        for (ExcelDiffDensity diffDensity : blueParams) {
            l+=diffDensity.getValueDLL();
            l+=diffDensity.getValueDRL();
            l+=diffDensity.getValueML();
            l+=diffDensity.getValueURL();
            l+=diffDensity.getValueULL();

            a+=diffDensity.getValueDLA();
            a+=diffDensity.getValueDRA();
            a+=diffDensity.getValueMA();
            a+=diffDensity.getValueURA();
            a+=diffDensity.getValueULA();

            b+=diffDensity.getValueULB();
            b+=diffDensity.getValueURB();
            b+=diffDensity.getValueMB();
            b+=diffDensity.getValueDRB();
            b+=diffDensity.getValueDLB();

            dAVGS.add(diffDensity.getFormulaDensityAVG());
        }
        this.formulaTotalBlueL = l/total;
        this.formulaTotalBlueA = a/total;
        this.formulaTotalBlueB = b/total;
        this.formulaBlueMutil = NumberUtil.max(dAVGS.toArray(new Double[blueParams.size()]))
                -NumberUtil.min(dAVGS.toArray(new Double[blueParams.size()]));

        for (ExcelDiffDensity diffDensity : blueParams) {
            diffDensity.setFormulaDRLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlueL - diffDensity.getValueDRL(), 2)
                            +Math.pow(this.formulaTotalBlueA - diffDensity.getValueDRA(), 2)
                            +Math.pow(this.formulaTotalBlueB - diffDensity.getValueDRB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaDLLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlueL - diffDensity.getValueDLL(), 2)
                            +Math.pow(this.formulaTotalBlueA - diffDensity.getValueDLA(), 2)
                            +Math.pow(this.formulaTotalBlueB - diffDensity.getValueDLB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaURLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlueL - diffDensity.getValueURL(), 2)
                            +Math.pow(this.formulaTotalBlueA - diffDensity.getValueURA(), 2)
                            +Math.pow(this.formulaTotalBlueB - diffDensity.getValueURB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaULLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlueL - diffDensity.getValueULL(), 2)
                            +Math.pow(this.formulaTotalBlueA - diffDensity.getValueULA(), 2)
                            +Math.pow(this.formulaTotalBlueB - diffDensity.getValueULB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaMLAB(
                    NumberUtil.round( Math.sqrt(Math.pow(this.formulaTotalBlueL - diffDensity.getValueML(), 2)
                            +Math.pow(this.formulaTotalBlueA - diffDensity.getValueMA(), 2)
                            +Math.pow(this.formulaTotalBlueB - diffDensity.getValueMB(), 2)
                    ), 2).doubleValue()
            );
            diffDensity.setFormulaLABAVG(diffDensity.calculateLABAVG());
        }
    }
}
